
function HS_setHour(inputObj){
    var iid = "mytimeselect";
    var calenderObj;
    if(document.getElementById(iid)){
      calenderObj = document.getElementById(iid);
    }else{
      calenderObj = document.createElement("span");
      calenderObj.id = iid
	  calenderObj.innerHTML = HS_hour(new Date());
	  calenderObj.style.position = "absolute";
    } 
	calenderObj.targetObj = inputObj;
	inputObj.parentNode.insertBefore(calenderObj,inputObj.nextSibling);
}
function HS_hour(){
	var lis = "";
	var style = "";
	/*可以把下面的css剪切出去独立一个css文件webjx.com*/
	style +="<style type='text/css'>";
	style +=".calender { width:170px; height:auto; font-size:12px; margin-right:14px; background:url(calenderbg.gif) no-repeat right center #fff; border:1px solid #397EAE; padding:1px}";
	style +=".calender ul {list-style-type:none; margin:0; padding:0;}";
	style +=".calender .day { background-color:#EDF5FF; height:20px;}";
	style +=".calender .day li,.calender .date li{ float:left; width:14%; height:37px; line-height:20px; text-align:center}";
	style +=".calender li a { text-decoration:none; font-family:Tahoma; font-size:11px; color:#333}";
	style +=".calender li a:hover { color:#f30; text-decoration:underline}";
	style +=".calender li a.hasArticle {font-weight:bold; color:#f60 !important}";
	style +=".lastMonthDate, .nextMonthDate {color:#bbb;font-size:11px}";
	style +=".selectThisYear a, .selectThisMonth a{text-decoration:none; margin:0 2px; color:#000; font-weight:bold}";
	style +=".calender .LastMonth, .calender .NextMonth{ text-decoration:none; color:#000; font-size:18px; font-weight:bold; line-height:16px;}";
	style +=".calender .LastMonth { float:left;}";
	style +=".calender .NextMonth { float:right;}";
	style +=".calenderBody {clear:both}";
	style +=".calenderTitle {text-align:center;height:20px; line-height:20px; clear:both}";
	style +=".today { background-color:#ffffaa;border:1px solid #f60; padding:2px}";
	style +=".today a { color:#f30; }";
	style +=".calenderBottom {clear:both; border-top:1px solid #ddd; padding: 3px 0; text-align:left}";
	style +=".calenderBottom a {text-decoration:none; margin:2px !important; font-weight:bold; color:#000}";
	style +=".calenderBottom a.closeCalender{float:right}";
	style +=".closeCalenderBox {float:right; border:1px solid #000; background:#fff; font-size:9px; width:11px; height:11px; line-height:11px; text-align:center;overflow:hidden; font-weight:normal !important}";
	style +="</style>";

	var now;
	if (typeof(arguments[0])=="string"){
		selectDate = arguments[0].split("-");
		var year = selectDate[0];
		var month = parseInt(selectDate[1])-1+"";
		var date = selectDate[2];
		now = new Date(year,month,date);
	}else if (typeof(arguments[0])=="object"){
		now = arguments[0];
	}
	var lastMonthEndDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+now.getMonth()+"-01").getDate();
	var lastMonthDate = WeekDay(now.getFullYear()+"-"+now.getMonth()+"-01");
	var thisMonthLastDate = HS_DateAdd("d","-1",now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-01");
	var thisMonthEndDate = thisMonthLastDate.getDate();
	var thisMonthEndDay = thisMonthLastDate.getDay();
	var todayObj = new Date();
	today = todayObj.getFullYear()+"-"+todayObj.getMonth()+"-"+todayObj.getDate();
	
	for (i=0; i<lastMonthDate; i++){  // Last Month's Date
		lis = "<li class='lastMonthDate'>"+lastMonthEndDate+"</li>" + lis;
		lastMonthEndDate--;
	}
	for (i=1; i<=thisMonthEndDate; i++){ // Current Month's Date

		if(today == now.getFullYear()+"-"+now.getMonth()+"-"+i){
			var todayString = now.getFullYear()+"-"+(parseInt(now.getMonth())+1).toString()+"-"+i;
			lis += "<li><a href=javascript:void(0) class='today' onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
		}else{
			lis += "<li><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+now.getFullYear()+"-"+(parseInt(now.getMonth())+1)+"-"+i+"'>"+i+"</a></li>";
		}
		
	}
	var j=1;
	for (i=thisMonthEndDay; i<6; i++){  // Next Month's Date
		lis += "<li class='nextMonthDate'>"+j+"</li>";
		j++;
	}
	
	var hour = new Array();
	var temp = "";
	var temp_hour = "";
	for(ii=8 ; ii<20 ; ii++){
	 temp_hour = (ii<10)?("0"+ii):ii;
	 temp += "<li><a href=javascript:void(0) onclick='_selectThisTime(this,\"hour_d_temp\")' title='" + temp_hour + "' >" + temp_hour + "点" +"</a></li>";
	
	}
	lis = temp;//小时选择
	lis += style;
	
	var minutes_temp = "";//分钟选择
	var temp_munutes = "";
	
	//alert(55%5);
	for(ii=0 ; ii<60 ; ii++){
	 temp_munutes = (ii<10)?("0"+ii):ii;
	 if(ii%5 == 0){
	 minutes_temp += "<li><a href=javascript:void(0) onclick='_selectThisTime(this,\"hour_f_temp\")' title='" + temp_munutes + "' >" + temp_munutes + "分" +"</a></li>";
	 }
	}
	
	//时间 小时 分
	var times_temp = "";
	times_temp += "<input type=text id=hour_d_temp size=2 maxlength=2 disabled />" + "点";
	times_temp += "<input type=text id=hour_f_temp size=2 maxlength=2 disabled />" + "分";


	var CalenderTitle = "<a href='javascript:void(0)' class='NextMonth' onclick=HS_calender(HS_DateAdd('m',1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='下月'>&raquo;</a>";
	CalenderTitle += "<a href='javascript:void(0)' class='LastMonth' onclick=HS_calender(HS_DateAdd('m',-1,'"+now.getFullYear()+"-"+now.getMonth()+"-"+now.getDate()+"'),this) title='上月'>&laquo;</a>";
	CalenderTitle += "<span class='selectThisYear'><a href='javascript:void(0)' onclick='CalenderselectYear(this)' title='单击选择年' >"+now.getFullYear()+"</a></span>年<span class='selectThisMonth'><a href='javascript:void(0)' onclick='CalenderselectMonth(this)' title='单击选择月'>"+(parseInt(now.getMonth())+1).toString()+"</a></span>月"; 


	if (arguments.length>1){
		arguments[1].parentNode.parentNode.getElementsByTagName("ul")[1].innerHTML = lis;
		arguments[1].parentNode.innerHTML = CalenderTitle;

	}else{
		//var CalenderBox = style+"<div class='calender'><div class='calenderTitle'>"+CalenderTitle+"</div><div class='calenderBody'><ul class='day'><li>日</li><li>一</li><li>二</li><li>三</li><li>四</li></ul><ul class='date' id='thisMonthDate'>"+lis+"</ul></div><div class='calenderBottom'><a href='javascript:void(0)' class='closeCalender' onclick='closeCalender(this)'>&times;</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+todayString+"'>今天</a></span></span></div></div>";
		var CalenderBox = style+"<div class='calender'>" + 
		"<div class='calenderTitle'>时间:" + times_temp + "</div>" +
		"<div class='calenderBody'>" +
		"<ul class='day' >"+"小时"+"</ul>"+
		"<ul class='date' id='thisMonthDate'>"+lis+"</ul></div>"+
		"<div class='calenderBody'><ul class='day' >"+"分钟"+"</ul>"+
		"<ul class='date' id='thisMonthDate'>"+minutes_temp+"</ul>"+
		"</div>"+
		"<div class='calenderBottom'><a href='javascript:void(0)' class=''  onclick='_setThisTime(this)'>确定</a>&nbsp;<a href='javascript:void(0)' class=''  onclick='closeCalender(this)'>&times;关闭</a><span><span><a href=javascript:void(0) onclick='_selectThisDay(this)' title='"+todayString+"'></a></span></span></div></div>";
		return CalenderBox;
	}
}

function _selectThisHour(d){
	var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode;
		boxObj.targetObj.value = d.title;
		boxObj.parentNode.removeChild(boxObj);
}
/**
时间控件  “确定” 按钮 触发事件
*/
function _setThisTime(d){

	var boxObj = d.parentNode.parentNode.parentNode;
		$('hour_d_temp').value = $_value('hour_d_temp')?$_value('hour_d_temp'):'08';
		$('hour_f_temp').value = $_value('hour_f_temp')?$_value('hour_f_temp'):'00';
		
		boxObj.targetObj.value = $_value('hour_d_temp') + ":" + $_value('hour_f_temp');
		boxObj.parentNode.removeChild(boxObj);
}
/**
时间空间设置小时 或分钟 临时值
d 当前对象
obj 预设置值的表单对象
*/
function _selectThisTime(d,obj){
    $_set_value(obj,d.title);
	//var boxObj = d.parentNode.parentNode.parentNode.parentNode.parentNode;
	//	boxObj.targetObj.value = d.title;
	//boxObj.parentNode.removeChild(boxObj);
}

/*验证登录ID是否合法*/
function checkLogID(logid){
     if(document.form1.uorlogid.value != "" && document.form1.uorlogid.value != logid){
       var url = context + "/system/user.do?method=checklogid&logid=" + logid;
       var res = sendRequest(url);
       var r = (res != 1);
       return r;
     }
     
     return true;
   }
   
   /*选择用户所属组*/
   function handleSelect(){
     var url = context + "/system/tree.do?method=selectgrouptree&type=radio";
     dialog(url,true,"组织机构",300,400);
   }
   
   
   
   /*保存提交*/
   function handleSubmit(){
     if(isblank(document.form1.HYSYD_ZT)){
        alert("请填写会议主题");
        document.form1.HYSYD_ZT.focus();
     }else if(confirm("确定提交")){
        document.form1.submit();
     }
   }
   
      /**审批提交 type  1  审核通过。  2 审核驳回。
      */
   function handleSubmit2(type){
   //开始时间
   My_setDate('HYSYD_KSSJ_DTAE','HYSYD_KSSJ_Hour','HYSYD_KSSJ');
   //结束时间
   My_setDate('HYSYD_JSSJ_DTAE','HYSYD_JSSJ_Hour','HYSYD_JSSJ');
     if(confirm("确定提交")){
        document.getElementById("HYSYD_SPZT").value = type;
        document.form1.submit();
     }
   }
   
   /**
人员选择树
types   checkbox 多选, radio 单选
selectuseronly
TreeAction.java 提供不同的选择方式
*/
//控件出发对象
//表单对象
var inputOBJ;
var inputOBJID;
//显示对象
var viewObj;

function selectPeople(obj,types,ids){
    inputOBJ = obj;
    inputOBJID = ids;
    
    var url = context + "/system/tree.do?method=selectuseronly&type=" + types + "&autoselect=false";

    if(document.getElementById(ids)){
       var s = document.getElementById(ids).value.split(",");
       dftids = "";
       for(var i=0;i<s.length;i++){
          if(s[i] != ""){
             dftids += "u" + s[i] + ",";
          }
       }
       url += "&defaultnode=" + dftids;
    }
    
    dialog(url,true,"选择人员",300,350);
}
/**
人员选择回调函数
ids id字符串
names 中文名称字符串
types 未知
**/ 
  function responseResult(ids,names,types){
  	 inputOBJ.value = names;
  	 if(document.getElementById(inputOBJID)){
  	    document.getElementById(inputOBJID).value = ids.replace(/u/g,"");
  	 }
  	 closeDialog();
  }
/**
拼装 会议开始时间 和结束时间
输入： 2008-1-1 ， 12:10 ， 
输出： 20080101121000 
*/
function My_setDate(date,time,target){
var result = "";
result += parseDate($_value(date));
result += parseTime($_value(time));  

$(target).value = result;
}


/**
* 输入 08:10
* 输出 081000  小时分钟秒
*/
function parseTime(obj){
    var s = "";
     
    if(obj.indexOf(":") > -1){
       hh = obj.substring(0,obj.indexOf(":"));
       mm = obj.substring(obj.lastIndexOf(":") + 1);
       //ss = obj.substring(obj.lastIndexOf(":") + 1);
       
       s = hh + mm + "00";
       
    }
    
    return s;
}

